package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConExplain;
import com.htgd.gardenexpo.dao.GeConExplainDao;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.service.GeConExplainService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 电子讲解表(GeConExplain)表服务实现类
 *
 * @author makejava
 * @since 2021-06-17 13:57:44
 */
@Service("geConExplainService")
public class GeConExplainServiceImpl implements GeConExplainService {
    @Resource
    private GeConExplainDao geConExplainDao;

    /**
     * 通过ID查询单条数据
     *
     * @param explainId 主键
     * @return 实例对象
     */
    @Override
    public GeConExplain queryById(Integer explainId) {
        return this.geConExplainDao.queryById(explainId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConExplain> queryAllByLimit(int offset, int limit) {
        return this.geConExplainDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<GeConExplain> getAllExplainByValue(PageQuery pageQuery) {
        return this.geConExplainDao.getAllExplainByValue(pageQuery);
    }

    @Override
    public List<GeConExplain> getExplainByTittle(String tittle) {
        return this.geConExplainDao.getExplainByTittle(tittle);
    }

    @Override
    public List<GeConExplain> getAllExplainByValueNoContent(PageQuery pageQuery) {
        return this.geConExplainDao.getAllExplainByValueNoContent(pageQuery);
    }

    /**
     * 新增数据
     *
     * @param geConExplain 实例对象
     * @return 实例对象
     */
    @Override
    public GeConExplain insert(GeConExplain geConExplain) {
        this.geConExplainDao.insert(geConExplain);
        return geConExplain;
    }

    /**
     * 修改数据
     *
     * @param geConExplain 实例对象
     * @return 实例对象
     */
    @Override
    public GeConExplain update(GeConExplain geConExplain) {
        this.geConExplainDao.update(geConExplain);
        return this.queryById(geConExplain.getExplainId());
    }

    /**
     * 通过主键删除数据
     *
     * @param explainId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer explainId) {
        return this.geConExplainDao.deleteById(explainId) > 0;
    }
}
